
<div class="templatemo-content-wrapper">
	<div class="templatemo-content">
		<ul class="nav nav-tabs mytabs">
		  <li ><a href="<?=site_url()?>/staff/index">员工列表</a></li>
		  <li class="active" role="presentation"><a href="<?=site_url()?>/staff/add"><i class="fa fa-plus"></i> 添加员工</a></li>
		</ul>
		<div class="row">
			<div class="col-md-12">
				<div class="table-responsive">
					 
					<form role="form" id="templatemo-preferences-form"
						onsubmit="return false;">
						<div class="row">
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">姓名</label> <input
									type="text" class="form-control" id="name" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">性别</label> 	
								<select class="form-control margin-bottom-15" id="gender">
               						 <option value="0">男</option>
               						 <option value="1">女</option>
            					</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">身份证号码</label> <input
									type="text" class="form-control" id="idcard" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">出生日期(YY-MM-DD)</label> <input
									type="text" class="form-control" id="birthday" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">学历</label> <input
									type="text" class="form-control" id="degree" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">住址</label> <input
									type="text" class="form-control" id="address" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">银行卡号</label> <input
									type="text" class="form-control" id="bankcard" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">手机号码</label> <input
									type="text" class="form-control" id="phone" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">部门</label>
								<select class="form-control margin-bottom-15" id="department">
                   						<?php foreach ($departments as $item):?>
                   						<option value="<?php echo $item['id'];?>"><?php echo $item['name'];?></option>
                     					<?php endforeach;?>
                  				</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">类型</label> 
								<select class="form-control margin-bottom-15" id="type">
               						 <option value="0">全职</option>
               						 <option value="1">兼职</option>
            					</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">是否缴纳社保</label> 
								<select class="form-control margin-bottom-15" id="security">
               						 <option value="0">是</option>
               						 <option value="1">否</option>
            					</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">是否缴纳公积金</label> 
								<select class="form-control margin-bottom-15" id="fund">
               						 <option value="0">是</option>
               						 <option value="1">否</option>
            					</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">是否缴纳商保</label> 
								<select class="form-control margin-bottom-15" id="insurance">
               						 <option value="0">是</option>
               						 <option value="1">否</option>
            					</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">职位状态</label> 	
								<select class="form-control margin-bottom-15" id="state">
               						 <option value="1">实习期</option>
               						 <option value="2">入职</option>
               						 <option value="3">离职</option>
            					</select>
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">入职日期(YY-MM-DD)</label> <input
									type="text" class="form-control" id="start" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="lastName" class="control-label">离职日期(YY-MM-DD)</label> <input
									type="text" class="form-control" id="end" value="">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">薪水</label> <input
									type="text" class="form-control" id="salary" value="">
							</div>
						</div>
						<div class="row templatemo-form-buttons">
							<div class="col-md-12">
								<button type="submit" class="btn btn-primary" id="submit_btn">添加</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function() {
		$("#submit_btn").click(function() {
			var name = $("#name").val();
			var gender = $("#gender").val();
			var idcard = $("#idcard").val();
			var birthday = $("#birthday").val();
			var degree = $("#degree").val();
			var address = $("#address").val();
			var bankcard = $("#bankcard").val();
			var phone = $("#phone").val();
			var department = $("#department").val();
			var type = $("#type").val();
			var security = $("#security").val();
			var fund = $("#fund").val();
			var insurance = $("#insurance").val();
			var state = $("#state").val();
			var start = $("#start").val();
			var end = $("#end").val();
			var salary = $("#salary").val();
			$.ajax({
				url : '<?php echo site_url('staff/save')?>',
				type : "post",
				async : true,
				data : {
					'name' : name,
					'gender' : gender,
					'idcard' : idcard,
					'birthday' : birthday,
					'degree' : degree,
					'address' : address,
					'bankcard' : bankcard,
					'phone' : phone,
					'department' : department,
					'type' : type,
					'security' : security,
					'fund' : fund,
					'insurance' : insurance,
					'state' : state,
					'start' : start,
					'end' : end,
					'salary' : salary
				},
				dataType : "json",
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
					}else{
						alert(data.msg);
					}
				}
			});
		});
	}); 
</script>